package org.coke.consumer.controller;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.config.annotation.DubboReference;
import org.coke.interfaces.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author weimin
 * @date 2024/4/6
 * @description
 */

@RestController
@RequestMapping("/users")
public class UserController {

    @DubboReference
    UserService userService;

    @GetMapping("/getUser")
    public String getUserName() throws InterruptedException {
         userService.service("xxxx", new StreamObserver<String>() {
             @Override
             public void onNext(String data) {
                 System.out.println(data);
             }

             @Override
             public void onError(Throwable throwable) {

             }

             @Override
             public void onCompleted() {

             }
         });
         return "success";
    }
}
